package com.bytedance.scenedemo.animatiom;

import com.bytedance.scene.ui.template.AppCompatScene;
import com.bytedance.scenedemo.ResourceTable;
import ohos.aafwk.content.Intent;
import ohos.agp.components.Component;
import ohos.agp.components.ComponentContainer;
import ohos.agp.components.LayoutScatter;
import ohos.agp.window.dialog.ToastDialog;

/**
 * Created by JiangQi on 8/29/18.
 */
public class SwipeBackDemo extends AppCompatScene {
    private boolean mSwipeBack = false;

    @Override
    protected Component onCreateContentView(LayoutScatter inflater, ComponentContainer container, Intent savedInstanceState) {
        Component component = inflater.parse(ResourceTable.Layout_swipe_back_demo, container, false);
        setTitle("");
        return component;
    }

    @Override
    public void onAbilityCreated(Intent savedInstanceState) {
        super.onAbilityCreated(savedInstanceState);
        setSwipeEnabled(true);
    }

    @Override
    protected void onSwipeBackEnd() {
        mSwipeBack = true;
        super.onSwipeBackEnd();
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        if (mSwipeBack) {
            showToast("侧滑返回");
        } else {
            showToast("非侧滑返回");
        }
    }
}
